//
// Created by tacom on 2022/8/22.
//
// 本类作为vascular算法调度的外部api，以及逻辑组织类存在
//

#ifndef CVCUDAIMPL_VASCULAR_H
#define CVCUDAIMPL_VASCULAR_H

#include "pybind11/stl.h"
#include "pybind11/numpy.h"
#include "opencv2/opencv.hpp"

#include "CNFD.cuh"
#include "intersection.h"
#include "hilditch.h"
#include "NumPyMatConvert.h"
#include "ApplicationConfig.h"
#include "CTBD.h"

class DLL_PUBLIC vascular {
    /** 类函数组织形式如下：
     *      1. public: 提供对外的函数接口
     *      2. private: xxStart, 相当于Adaptor,转换数据类型到规定算法
     */
public:
    // python wrapper
    typedef pybind11::array_t<unsigned char> CV_ARRAY;
    typedef std::pair<pybind11::array_t<unsigned char>, std::vector<unsigned>> CNFD_RES;
    typedef std::vector<std::vector<int>> USABLE_MATRIX;

    CV_ARRAY hilditch(CV_ARRAY& input);
    intersection::INTERSECTIONS Intersection(CV_ARRAY &input);

    CNFD_RES CNFD(CV_ARRAY &input, USABLE_MATRIX &matrixShape,
                  std::vector<unsigned int> &resultList, int height, int width, int stride);

    CTBD::CTBD_LIST CTBDWrapper(CV_ARRAY &input, USABLE_MATRIX &matrixShape,
                                int height, int width, int stride,
                                CTBD::FILE_NAME_LIST &fileNameList, CTBD::FILE_PATH &refineSavePath,
                                CTBD::FILE_PATH &segSavePath);

private:
    // variable
    intersection sectionPredictor;
    CTBD ctbdPredictor;

    // c++ predict
    CV_ARRAY
    CNFDStart(cv::Mat& input, USABLE_MATRIX &matrixShape,
              std::vector<unsigned int> &resultList, int height, int width, int stride);

};


#endif //CVCUDAIMPL_VASCULAR_H
